<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>跳转首页功能</title>
    <style>
        p{
            text-align: center;
        }
        span{
            color: red;
        }
    </style>
</head>
<body>
    <p id="title"><span id="second">5</span>秒之后 , 自动跳转百度......</p>
    <script>
        var time = 5;
        function fun() {
            time--;
            if (time <= 0) {
                location.href = "https://www.baidu.com";
            }
            var second = document.getElementById("second");
            second.innerHTML = time;
        }
        setInterval(fun,1000);
    </script>
</body>

</html>